package com.tfswx.fljdmxyy.api;

import com.tfswx.fljdmxyy.dto.sjgl.*;
import com.tfswx.fljdmxyy.query.sjgl.*;
import com.tfswx.fljdmxyy.service.SjglService;
import com.tfswx.newbie.boot.starter.page.PageParam;
import com.tfswx.newbie.boot.starter.page.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 数据管理
 *
 * @Author 陈文佳
 * @Date 2023/03/24
 */
@Api(tags = "数据管理")
@RequestMapping("api/sjgl")
@RestController
public class SjglController {

    @Resource
    private SjglService sjglService;

    @ApiOperation("获取实体表名列表")
    @PostMapping("/queryYwst")
    public List<YwstQueryResult> queryYwst(@RequestBody @Validated YwstQueryParam param) {
        return sjglService.queryYwst(param);
    }

    @ApiOperation("修改实体表名")
    @PostMapping("/updateYwst")
    public Boolean updateYwst(@RequestBody @Validated YwstUpdateInputDTO dto) {
        return sjglService.updateYwst(dto);
    }

    @ApiOperation("查询条件收藏")
    @PostMapping("/getTjsc")
    public TjscGetOutputDTO getTjsc(@RequestBody @Validated TjscGetInputDTO dto) {
        return sjglService.getTjsc(dto);
    }

    @ApiOperation("获取查询条件收藏列表")
    @PostMapping("/queryTjsc")
    public List<TjscQueryResult> queryTjsc(@RequestBody @Validated TjscQueryParam param) {
        return sjglService.queryTjsc(param);
    }

    @ApiOperation("添加实体字段")
    @PostMapping("/addStzd")
    public StzdAddOutputDTO addStzd(@RequestBody @Validated StzdAddInputDTO dto) {
        return sjglService.addStzd(dto);
    }

    @ApiOperation("查询实体字段")
    @PostMapping("/getStzd")
    public StzdGetOutputDTO getStzd(@RequestBody @Validated StzdGetInputDTO dto) {
        return sjglService.getStzd(dto);
    }

    @ApiOperation("修改查询条件收藏")
    @PostMapping("/updateTjsc")
    public Boolean updateTjsc(@RequestBody @Validated TjscUpdateInputDTO dto) {
        return sjglService.updateTjsc(dto);
    }

    @ApiOperation("删除实体表名")
    @PostMapping("/deleteYwst")
    public Boolean deleteYwst(@RequestBody @Validated YwstDeleteInputDTO dto) {
        return sjglService.deleteYwst(dto);
    }

    @ApiOperation("获取实体字段列表")
    @PostMapping("/queryStzd")
    public List<StzdQueryResult> queryStzd(@RequestBody @Validated StzdQueryParam param) {
        return sjglService.queryStzd(param);
    }

    @ApiOperation("删除条件收藏")
    @PostMapping("/deleteTjsc")
    public Boolean deleteTjsc(@RequestBody @Validated TjscDeleteInputDTO dto) {
        return sjglService.deleteTjsc(dto);
    }

    @ApiOperation("添加实体表名")
    @PostMapping("/addYwst")
    public YwstAddOutputDTO addYwst(@RequestBody @Validated YwstAddInputDTO dto) {
        return sjglService.addYwst(dto);
    }

    @ApiOperation("删除实体字段")
    @PostMapping("/deleteStzd")
    public Boolean deleteStzd(@RequestBody @Validated StzdDeleteInputDTO dto) {
        return sjglService.deleteStzd(dto);
    }

    @ApiOperation("添加查询条件收藏")
    @PostMapping("/addTjsc")
    public TjscAddOutputDTO addTjsc(@RequestBody @Validated TjscAddInputDTO dto) {
        return sjglService.addTjsc(dto);
    }

    @ApiOperation("查询实体表名")
    @PostMapping("/getYwst")
    public YwstGetOutputDTO getYwst(@RequestBody @Validated YwstGetInputDTO dto) {
        return sjglService.getYwst(dto);
    }

    @ApiOperation("修改实体字段")
    @PostMapping("/updateStzd")
    public Boolean updateStzd(@RequestBody @Validated StzdUpdateInputDTO dto) {
        return sjglService.updateStzd(dto);
    }

    @ApiOperation("查询业务字段关系")
    @PostMapping("/queryYwzdgx")
    public List<YwzdgxQueryResult> queryYwzdgx() {
        return sjglService.queryYwzdgx();
    }

    @ApiOperation("组合查询")
    @PostMapping(value = "/queryData")
    public PageResult<Map<String, Object>> queryData(@RequestBody @Validated PageParam<DataQueryParam> param) {
        return sjglService.queryData(param);
    }

    @ApiOperation("导出组合查询(当前页)")
    @PostMapping(value = "/exportData")
    public void exportData(@RequestBody @Validated PageParam<DataQueryParam> param, HttpServletResponse response) {
        sjglService.exportData(param, response);
    }

    @ApiOperation("导出组合查询(全部)")
    @PostMapping(value = "/exportAll")
    public void exportAll(@RequestBody @Validated PageParam<DataQueryParam> param, HttpServletResponse response) {
        sjglService.exportAll(param, response);
    }

    @ApiOperation("查询实体信息")
    @PostMapping("/queryStxx")
    public List<StxxQueryResult> queryStxx() {
        return sjglService.queryStxx();
    }

    @ApiOperation("添加业务实体字段")
    @PostMapping("/addYwstzd")
    public Boolean addYwstzd(@RequestBody @Validated YwstzdAddInputDTO dto) {
        return sjglService.addYwstzd(dto);
    }
}
